package com.example.snashuitraverl.demos.test;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class RabbitMQConfig {
    /**
     *定义交换机
     */
    private String EXCHANGE_SPRINGBOOT_NAME = "/cat_ex";
    /**
     * 测试队列
     */
    private String FANOUT_TEST_QUEUE = "fanout_test_queue";
    @Bean
    public Queue testQueue(){
        return new Queue(FANOUT_TEST_QUEUE);
    }
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange(EXCHANGE_SPRINGBOOT_NAME);
    }
    /**
     * 关联绑定交换机
     */
    @Bean
    public Binding BindingTestFanoutExchange(Queue testQueue, FanoutExchange fanoutExchange){
        return BindingBuilder.bind(testQueue).to(fanoutExchange);
    }
}
